package com.test.lock;

import java.util.concurrent.TimeUnit;

public class DaemonThreadDemo {

	public static void main(String[] args) {
		Thread mainThread = new Thread(new ChildThread() {
			@Override
			public void run() {
				Thread childThread = new Thread(new ChildThread());
				childThread.setDaemon(true);
				childThread.start();
				System.out.println("I am mainThread...");
			}
		});
		mainThread.start();

	}

	public static class ChildThread implements Runnable {
		public void run() {
			while (true) {
				System.out.println("I am ChildThread");
				try {
					TimeUnit.SECONDS.sleep(5);
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
			}
		}
	}
}
